//
//  DYMemberBillVC.m
//  kafuMerchant
//
//  Created by 帝云科技 on 2018/9/19.
//  Copyright © 2018年 帝云科技. All rights reserved.
//

#import "DYMemberBillVC.h"
#import "DYPaymentRecordsView.h"
#import "DYTimePickerView.h"
#import "DYMemberBillCell.h"
#import "DYMemberBillView.h"

@interface DYMemberBillVC ()

@property (nonatomic,strong)DYPaymentRecordsView *timeView;
@property (nonatomic,strong)DYMemberBillView *billView;
@property (nonatomic,strong)DYTimePickerView *pickerView;
@property (nonatomic,assign)NSInteger timeType;
@end

@implementation DYMemberBillVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self navigationBar];
}
-(void)navigationBar
{
    self.navigationItem.title=@"会员账单";
    [self createRightBarItem:nil titleString:@"查询"];
    UIButton *rightBtn =self.navigationItem.rightBarButtonItem.customView;
    [rightBtn setTitleColor:[UIColor xhq_base] forState:UIControlStateNormal];
}
-(void)rightClick
{
    XHQHUDTEXT(@"查询");
}
-(void)dy_initData
{
    [super dy_initData];
    
    self.style=DYTableViewStyleGrouped;
}
-(void)dy_refresh
{
    [self.tableView.mj_header endRefreshing];
}
-(void)dy_initUI
{
    [super dy_initUI];
    
    [self.view addSubview:self.timeView];
    
    self.view.backgroundColor=[UIColor xhq_grayblue];
    self.tableView.frame=CGRectMake(0, self.timeView.xhq_bottom, kScreenWidth, kScreenHeight-kNavigationStatusHeight-self.timeView.xhq_bottom);
    self.tableView.tableHeaderView=self.billView;
    self.tableView.emptyDataSetSource=self;
    self.tableView.emptyDataSetDelegate=self;
    [self.tableView registerClass:[DYMemberBillCell class] forCellReuseIdentifier:@"DYMemberBillCell"];
    
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 3;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return BILIHEIGHT(168);
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return BILIHEIGHT(10);
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
   DYMemberBillCell *cell=[tableView dequeueReusableCellWithIdentifier:@"DYMemberBillCell" forIndexPath:indexPath];
    return cell;
}

#pragma mark - 暂无数据delegate datasource
-(UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView
{
    return IMG(@"img_nodate");
}
- (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView {
    NSString *title = @"暂无数据";
    NSDictionary *attributes = @{
                                 NSFontAttributeName:kFont(15),
                                 NSForegroundColorAttributeName:[UIColor xhq_assist]
                                 };
    return [[NSAttributedString alloc] initWithString:title attributes:attributes];
}

-(DYPaymentRecordsView *)timeView
{
    if (!_timeView) {
        _timeView=[[DYPaymentRecordsView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, BILIHEIGHT(70))];
        @weakify(self);
        _timeView.recordTimeBlock = ^(NSInteger timeType) {
            @strongify(self);
            self.timeType=timeType;
            if (timeType==0) {
                //开始时间
                self.pickerView.toolbarTitle=@"请选择开始时间";
            }else{
                self.pickerView.toolbarTitle=@"请选择结束时间";
            }
            [self.pickerView show];
        };
    }
    return _timeView;
}
-(DYTimePickerView *)pickerView
{
    if (!_pickerView) {
        _pickerView=[[DYTimePickerView alloc]initWithFrame:CGRectZero];
        
        @weakify(self);
        _pickerView.timePickerBlock = ^(NSString *time) {
            @strongify(self);
            if (self.timeType==0) {
                self.timeView.startTime=time;
            }else{
                self.timeView.endTime=time;
            }
        };
    }
    return _pickerView;
}
-(DYMemberBillView *)billView
{
    if (!_billView) {
        _billView=[[DYMemberBillView alloc]initWithFrame:CGRectMake(0,BILIHEIGHT(10), kScreenWidth, BILIHEIGHT(77))];
    }
    return _billView;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
